package com.hrg.rds.biz.robot.domain;

import lombok.Data;

import java.util.List;

@Data
public class Jack extends Ret {
	//运行模式, false = 手动, true = 自动
	private Boolean jack_mode;
	//运行状态, 0x00 = 上升中，0x01 = 上升到位，0x02 = 下降中，0x03 = 下降到位，0x04 = 停止，0xFF = 执行失败
	private Integer jack_state;
	//顶升是否启用, false = 未启用, true = 启用
	private Boolean jack_enable;
	//顶升错误码
	private Integer jack_error_code;
	//顶升机构上是否有料, false = 无料, true = 有料
	private Boolean jack_isFull;
	//顶升机构电机速率, 单位: mm/s
	private Double jack_speed;
	//顶升机构是否急停, false = 未急停, true = 急停
	private Boolean jack_emc;
	//顶升当前的高度，单位: m
	private Double jack_height;
	//外设中的用户自定义数据
	private List<Integer> peripheral_data;

	// 成功未判断顶升高度
	public boolean loadSuccess() {
		return jack_enable && !jack_emc && jack_state == 0x01;
	}
	public boolean unloadSuccess() {
		return jack_enable && !jack_emc && jack_state == 0x03;
	}
	public boolean setHeightSuccess(double height) {
		return jack_enable && !jack_emc && (Double.compare(jack_height, height)==0) && (jack_state == 0x01||jack_state == 0x03);
	}
	public boolean isStop() {
		return jack_enable && !jack_emc && jack_state == 0x04;
	}
	public boolean isFailed() {
		return jack_state == 0xFF;
	}
}
